#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
using ll=long long;
const int N=1e5+10;

ll a[N],b[N];
struct node{
	ll x,y;
	bool operator <(const node& p) const
	{
		return y>p.y;
	}
};
int main()
{
	int n,k;
	cin>>n>>k;
	
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	vector<node> v;
	for(int i=1;i<=n;i++)
	{
		node t({a[i],b[i]});
		v.push_back(t);
	}	
	sort(v.begin(),v.end());
	ll sum=0;
	ll ret=0;
	priority_queue<ll,vector<ll>,greater<ll>> q;
	for(int i=0;i<n;i++)
	{
		q.push(v[i].x);
		sum+=v[i].x;
		if(i>=k-1)
		{
			ret=max(ret,sum*v[i].y);
			sum-=q.top();
			q.pop();
		}
	}
	cout<<ret<<endl;
	return 0;
}
